package com.lc202310;

/**
 * Description:
 *
 * @Create 2023/10/25 22:59
 * @Version 1.0
 */
public class Solution75 {
    public void sortColors(int[] nums) {
        int index = 0;
        int length = nums.length;
        for (int i = 0; i < length; i++) {
            if (nums[i] == 0) {
                int tmp = nums[index];
                nums[index] = nums[i];
                nums[i] = tmp;
                index++;
            }
        }
        for (int i = index; i < length; i++) {
            if (nums[i] == 1) {
                int tmp = nums[index];
                nums[index] = nums[i];
                nums[i] = tmp;
                index++;
            }
        }
    }
}
